package com.sjhang.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sjhang.entity.TbVideo;
import com.sjhang.mapper.TbVideoMapper;
import com.sjhang.service.TbVideoService;
import com.sjhang.utils.ListParamVo;
import com.sjhang.utils.ResultResponse;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 教学视频 — 服务实现类
 *
 */
@Service
public class TbVideoServiceImpl extends ServiceImpl<TbVideoMapper, TbVideo> implements TbVideoService {

    @Resource
    private TbVideoMapper tbVideoMapper;
    /**
     * @description 查询视频
     * @params [listParamVo]
     */
    @Override
    public ResultResponse selectVideo(ListParamVo listParamVo) {
        IPage<TbVideo> page = tbVideoMapper.selectVideoAll(
                new Page<TbVideo>(listParamVo.getCurrent(),listParamVo.getSize()),
                listParamVo.getParamMap().get("title")
        );
        return ResultResponse.SUCCESS(page);
    }

    /***
     * @description 新增视频
     * @params [tbVideo]
     */
    @Override
    public ResultResponse insertVideo(TbVideo tbVideo) {
        int insert = tbVideoMapper.insert(tbVideo);
        return ResultResponse.SUCCESS();
    }
    /***
     * @description 修改视频信息，
     * @params [tbVideo]
     */
    @Override
    public ResultResponse updateVideo(TbVideo tbVideo) {
        int insert = tbVideoMapper.updateById(tbVideo);
        return ResultResponse.SUCCESS();
    }
    /***
     * @description 删除视频信息
     * @params [tbVidel]
     */
    @Override
    public ResultResponse deleteVideo(Long tbVidel) {
        int i = tbVideoMapper.deleteById(tbVidel);
        return ResultResponse.SUCCESS();
    }


}
